var udp = require('dgram');
function createUdpBy(udplistenport, udplistenIp,callback) {// 端口，ip string
    let server = udp.createSocket('udp4');
    server.bind(udplistenport, udplistenIp, function () {
        let s=server.address();
        console.log('udp://' + s.address + ":" + s.port);
        //当服务启动后,开启后台消息轮询服务
       callback&&callback();
    });
    server.on("connect", function () {
        //console.log(arguments)
    });
    server.on('message', (msg, rinfo) => {
      // console.log(msg);
    });
    server.on('error', (err) => {
        console.log(err);
    });
    return server;
}
module.exports.createUdp=createUdpBy;
global.createUdp=createUdpBy;